package com.yunyan.util;

import com.alibaba.excel.EasyExcel;
import com.yunyan.entity.HistoryData;
import com.yunyan.entity.RankData;
import com.yunyan.entity.SchoolData;
import com.yunyan.util.listener.HistoryListener;
import com.yunyan.util.listener.RankListener;
import com.yunyan.util.listener.SchoolListener;

import java.util.List;

// excel 解析类
public class ExcelParser {

    // 一分一档 excel 文件解析
    public static List<RankData> parseRank(String filePath) {
        RankListener rankListener = new RankListener();
        EasyExcel.read(filePath, RankData.class, rankListener).doReadAll();
        return rankListener.getDataList();
    }


    // 历史投档线 - 文科
    public static List<HistoryData> parseHistory(String filePath) {
        HistoryListener rankListener = new HistoryListener();
        EasyExcel.read(filePath, HistoryData.class, rankListener).doReadAll();
        return rankListener.getDataList();
    }

    public static List<SchoolData> parseSchool(String filePath) {
        SchoolListener rankListener = new SchoolListener();
        EasyExcel.read(filePath, SchoolData.class, rankListener).doReadAll();
        return rankListener.getDataList();
    }

    public static void main(String[] args) {
        parseHistory(System.getProperty("user.dir") + "/文科/2023本科.xlsx");
    }
}
